using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Reflection;
using System.Text;
using System.Windows.Forms;


namespace ALToolkit.CS.WindowsForms.SplashScreen {
    public partial class frmSplash : Form {

        #region Private Delegates

        private delegate void SetControlTextHandler(Control iControl, string iText);

        #endregion

        #region Private Fields

        private string mMessage;

        #endregion

        #region Constructors

        public frmSplash() {
            InitializeComponent();
        }

        #endregion

        #region Public Properties

        public string Message {
            get { return mMessage; }
            set {
                mMessage = value;
                this.SetControlText(this.lblMessage, this.TrimMessage(value));
            }
        }

        #endregion

        #region Private Functions

        private string TrimMessage(string iMessage) {
            if (iMessage.Length > 300) return iMessage.Substring(0, 300) + "...";
            return iMessage;
        }

        private void SetControlText(Control iControl, string iText) {
            if (this.InvokeRequired) {
                this.Invoke(new SetControlTextHandler(SetControlText), new object[] { iControl, iText });
            } else {
                iControl.Text = iText;
            }
        }

        #endregion

        #region Event Handlers

        private void frmSplash_Load(System.Object sender, System.EventArgs e) {
            FileVersionInfo fv;
            fv = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
            this.lblTitle.Text = fv.FileDescription;
            this.lblVersion.Text = fv.FileVersion;
            this.lblCopyright.Text = fv.LegalCopyright;
        }

        #endregion

    }
}